package com.baizhi.genericity3;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 泛型的边界问题
 */
public class GemerityDemo {
    public static void main(String[] args) {
        Collection<Integer> c1 = new ArrayList<>();
        Collection<Double> c2 = new ArrayList<>();
        Collection<Boolean> c3 = new ArrayList<>();
        Collection<String> c4 = new ArrayList<>();
        Collection<Object> c5 = new ArrayList<>();
        Collection<Number> c6 = new ArrayList<>();


        ShowCollectionUtil scu = new ShowCollectionUtil();
        scu.getElement(c1);//Integer是Number的子类 ,上限是number
        scu.getElement(c2); //DOuble是Number的子类  上限是number
        //scu.getElement(c3); //类型不匹配
        scu.getElement(c6); //上限是number


        //scu.showElement(c1); //Integer是Number子类， 下限是Number
       // scu.showElement(c2); //Integer是Number子类， 下限是Number
        scu.showElement(c6);
       // scu.showElement(c3); //类型不匹配
        scu.showElement(c5); //Object是Number的父类， 下限是Number
    }
}
